//
//  SelectorEncodingPreprocessorTest.h
//  test_simple_project
//
//  选择器、编码和预处理器指令测试文件 - 修复版本
//

#import <Foundation/Foundation.h>
#import <objc/runtime.h>

// 预处理器条件编译测试
#if TARGET_OS_IOS
    #define PLATFORM_SPECIFIC_STRING @"iOS Platform"
#elif TARGET_OS_MAC
    #define PLATFORM_SPECIFIC_STRING @"macOS Platform"
#else
    #define PLATFORM_SPECIFIC_STRING @"Unknown Platform"
#endif

// 版本条件编译
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_10_0
    #define SUPPORTS_MODERN_API 1
#else
    #define SUPPORTS_MODERN_API 0
#endif

// 宏定义测试
#define MAX_RETRY_COUNT 3
#define DEFAULT_TIMEOUT 30.0
#define LOG_ENABLED 1

// 带参数的宏 - 修复: 使用更安全的类型检查
#define SAFE_PERFORM_SELECTOR(target, selector) \
    do { \
        if ((target) && [(target) respondsToSelector:(selector)]) { \
            [(target) performSelector:(selector)]; \
        } \
    } while(0)

// 字符串化宏
#define STRINGIFY(x) #x
#define TO_STRING(x) STRINGIFY(x)

// 条件日志宏
#if LOG_ENABLED
    #define DEBUG_LOG(fmt, ...) NSLog(@"[DEBUG] " fmt, ##__VA_ARGS__)
#else
    #define DEBUG_LOG(fmt, ...)
#endif

// pragma mark指令测试
#pragma mark - Interface Declaration

@interface SelectorEncodingPreprocessorTest : NSObject

// 选择器测试相关属性
@property (strong, nonatomic) id target;
@property (assign, nonatomic) SEL cachedSelector;

// 编码测试相关属性
@property (strong, nonatomic) NSString *encodingInfo;

#pragma mark - Selector Testing Methods

// 基本选择器测试
- (void)testBasicSelectors;
- (void)testSelectorComparison;
- (void)testSelectorFromString;
- (void)testSelectorValidation;

// 动态选择器调用
- (void)testDynamicSelectorInvocation;
- (void)testSelectorWithParameters:(NSString *)param1 andValue:(NSNumber *)param2;
- (NSString *)selectorReturningValue;

// 选择器响应测试
- (void)testSelectorResponds;
- (void)testOptionalSelectorCalls;

#pragma mark - Encoding Testing Methods

// 基本类型编码测试
- (void)testBasicTypeEncoding;
- (void)testStructureEncoding;
- (void)testPointerEncoding;
- (void)testProtocolEncoding;

// 方法签名测试
- (void)testMethodSignatures;
- (void)testComplexMethodSignature:(NSString *)string 
                           integer:(NSInteger)integer 
                             block:(void(^)(NSString *))block;

#pragma mark - Preprocessor Testing Methods

// 条件编译测试
- (void)testConditionalCompilation;
- (void)testPlatformSpecificCode;
- (void)testVersionSpecificCode;

// 宏定义测试
- (void)testMacroDefinitions;
- (void)testParameterizedMacros;
- (void)testStringifyMacros;

// pragma指令测试
- (void)testPragmaDirectives;

#pragma mark - Runtime Inspection Methods

// 运行时信息获取
- (void)testRuntimeClassInspection;
- (void)testRuntimeMethodInspection;
- (void)testRuntimePropertyInspection;
- (void)testRuntimeProtocolInspection;

#pragma mark - Preprocessor Condition Testing

// 不同编译条件下的声明
#if SUPPORTS_MODERN_API
- (void)modernAPIMethod API_AVAILABLE(ios(10.0));
#endif

#ifdef DEBUG
- (void)debugOnlyMethod;
#endif

#ifndef NDEBUG
- (void)debugModeMethod;
#endif

@end

#pragma mark - Test Helper Protocol

@protocol SelectorTestProtocol <NSObject>

@required
- (void)requiredMethodForSelectorTest;

@optional
- (void)optionalMethodForSelectorTest;
- (NSString *)optionalMethodWithReturn;

@end

#pragma mark - Test Helper Class

@interface SelectorTestHelper : NSObject <SelectorTestProtocol>

- (void)helperMethod;
- (void)methodWithParameter:(NSString *)parameter;
- (NSString *)methodReturningString;
- (void)methodWithMultipleParameters:(NSString *)string 
                              number:(NSNumber *)number 
                               array:(NSArray *)array;

@end

#pragma mark - C Structure for Encoding Tests

typedef struct {
    int intValue;
    float floatValue;
    char *stringValue;
} TestStructure;

typedef struct {
    CGPoint point;
    CGSize size;
    NSInteger tag;
} ComplexStructure;

// 全局函数声明
void GlobalFunctionForTesting(void);
NSString *GlobalFunctionWithReturn(NSString *input);
void GlobalFunctionWithParameters(int value1, float value2, const char *string);
